home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
L' Effet Pommier 3
/
L'Effet Pommier - Volume 03.iso
/
Programmation
/
Gooey1.3.1
/
C Templates
/
mmMenu.c
< prev
next >
Wrap
Text File
|
1993-12-27
|
6KB
|
222 lines
$$Message MM Menu, mm:mmMenu$Prototype.name$.h
$$File mm:mmMenu$Prototype.name$.h
/* $CopyRight$ */
/* mmMenu$Prototype.name$ Handle menus
File name: mmMenu$Prototype.name$.h
Function: This contains the routines to handle menus.
History: $Date$ Original by $Author$
*/
/* ======================================================= */
/* ======================================================= */
#ifdef __cplusplus
extern "C" {
#endif
/* Initialize the menubar */
void Init_My_Menus(void);
/* Handle the menu selection */
void Handle_My_Menu( short theMenu,short theItem);
#ifdef __cplusplus
}
#endif
/* ======================================================= */
/* ======================================================= */
$$CloseFile
$$Message MM Menu, mm:mmMenu$Prototype.name$.c
$$File mm:mmMenu$Prototype.name$.c
/* $CopyRight$ */
/* mmMenu$Prototype.name$ Handle menus
File name: mmMenu$Prototype.name$.c
Function: This contains the routines to handle menus.
History: $Date$ Original by $Author$
*/
#include "mmCommon$Prototype.name$.h" /* Common */
#include "Common$Prototype.name$.h" /* Common */
#include "mmMenu$Prototype.name$.h" /* This file */
#include "menu$Prototype.name$.h"
$$Loop Menus
static void DoMenu$Menu.name$(short theItem); /* Handle this menu list, $Menu.FullName$ */
$$EndLoop Menus
$$Loop HierMenus
static void DoMenu$Menu.name$(short theItem); /* Handle this menu list, $Menu.FullName$ */
$$EndLoop HierMenus
/* ======================================================= */
/* ======================================================= */
/* Routine: Init_My_Menus */
/* Purpose: Load in the menu lists and initialize the menubar */
void Init_My_Menus(void)
{
ClearMenuBar(); /* Clear any old menu bars */
$$Loop Menus
/* This menu is $Menu.FullName$ */
Menu_$Menu.name$ = GetMenu(Res_Menu_$Menu.name$); /* Get the menu from the resource file */
InsertMenu(Menu_$Menu.name$,0); /* Insert this menu into the menu bar */
$$if Menu.Apple
AddResMenu(Menu_$Menu.name$,'DRVR'); /* Add in DAs */
$$endif
$$if Menu.File
$$endif
$$if Menu.Edit
$$endif
$$EndLoop Menus
$$Loop HierMenus
/* This menu is $Menu.FullName$ */
Menu_$Menu.name$ = GetMenu(Res_Menu_$Menu.name$); /* Get the menu from the resource file */
InsertMenu(Menu_$Menu.name$,-1); /* Insert this menu into the menu bar */
$$EndLoop HierMenus
AddExtraMenus(); /* Add any extra menu lists */
DrawMenuBar(); /* Draw the menu bar */
}
/* ======================================================= */
$$Loop Menus
/* Routine: DoMenu$Menu.name$ */
/* Purpose: Handle all menu items in this list */
static void DoMenu$Menu.name$(short theItem)
{
Boolean SkipProcessing; /* TRUE says skip processing */
$$if Menu.Apple
short DNA; /* For opening DAs */
Str255 DAName; /* For getting DA name */
GrafPtr SavePort; /* Save current port when opening DAs */
$$endif
$$if Menu.Edit
Boolean BoolHolder; /* For SystemEdit result */
$$endif
SkipProcessing = false; /* Set to not skip the processing of this menu item */
Do_$Menu.name$Menu(true,theItem,&SkipProcessing); /* Pre menu handler */
if (SkipProcessing == false) /* See if process the menu list */
{
$$if Menu.Edit
BoolHolder = SystemEdit(theItem - 1); /* Let the DA do the edit to itself */
if (!BoolHolder) /* If not a DA then we get it */
{
$$endif
switch (theItem) /* Handle all commands in this menu list */
{
$$Loop MenuItems
case MItem_$MenuItem.name$: /* For item $MenuItem.FullName$ */
$$Link Menu
$$if Menu.Quit
doneFlag = true; /* Quit */
$$endif
break;
$$EndLoop MenuItems
default: /* allow other buttons, trap for debug */
$$if Menu.Apple
GetPort(&SavePort); /* Save the current port */
GetItem(Menu_$Menu.name$,theItem, DAName); /* Get the name of the DA selected */
DNA = OpenDeskAcc(DAName); /*Open the DA selected */
SetPort(SavePort); /* Restore to the saved port */
$$endif
break; /* end of otherwise */
} /* end of switch */
$$if Menu.Edit
}
$$endif
}
Do_$Menu.name$Menu(false,theItem,&SkipProcessing); /* Post menu handler */
}
/* ======================================================= */
$$EndLoop Menus
$$Loop HierMenus
/* Routine: DoMenu$Menu.name$ */
/* Purpose: Handle all menu items in this list */
static void DoMenu$Menu.name$(short theItem)
{
Boolean SkipProcessing; /* TRUE says skip processing */
SkipProcessing = false; /* Set to not skip the processing of this menu item */
Do_$Menu.name$Menu(true,theItem,&SkipProcessing); /* Pre menu handler */
if (SkipProcessing == false) /* See if process the menu list */
{
switch (theItem) /* Handle all commands in this menu list */
{
$$Loop MenuItems
case MItem_$MenuItem.name$: /* For item $MenuItem.FullName$ */
$$Link Menu
break;
$$EndLoop MenuItems
default: /* allow other buttons, trap for debug */
break; /* end of otherwise */
} /* end of switch */
}
Do_$Menu.name$Menu(false,theItem,&SkipProcessing); /* Post menu handler */
}
/* ======================================================= */
$$EndLoop HierMenus
/* ======================================================= */
/* Routine: Handle_My_Menu */
/* Purpose: Vector off to the appropiate menu list handler */
void Handle_My_Menu(short theMenu,short theItem)
{
switch (theMenu) /* Do selected menu list */
{
$$Loop Menus
case Res_Menu_$Menu.name$:
DoMenu$Menu.name$(theItem); /* Go handle this list, $Menu.FullName$ */
break;
$$EndLoop Menus
$$Loop HierMenus
case Res_Menu_$Menu.name$:
DoMenu$Menu.name$(theItem); /* Go handle this list, $Menu.FullName$ */
break;
$$EndLoop HierMenus
default: /* allow other buttons, trap for debug */
Handle_Other_Menus(theMenu,theItem); /* Handle other special menus */
break; /* end of otherwise */
} /* end of switch */
HiliteMenu(0); /* Turn menu selection off */
}
/* ======================================================= */
/* ======================================================= */
$$CloseFile